//
//  AXFShopCollectViewController.m
//  MineOrderUI
//
//  Created by mac2 on 16/11/20.
//  Copyright © 2016年 mac2. All rights reserved.
//

#import "AXFShopCollectViewController.h"
#import "AXFNewAddShopViewController.h"
#import "AXFWhiteNavView.h"
#import "AXFWhiteNavView.h"
@interface AXFShopCollectViewController ()<AXFWhiteNavViewDelegate>
@end

@implementation AXFShopCollectViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

//添加navigationController
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    self.navigationController.navigationBar.hidden = NO;
}


//编辑按钮点击事件
-(void)editor{
    
}

//新增店铺按钮的点击事件
-(void)addShop:(UIButton *)sender{
    AXFNewAddShopViewController *newAddVc = [[AXFNewAddShopViewController alloc]init];
    
    [self.navigationController pushViewController:newAddVc animated:YES];
    //按钮颜色:
//    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
//    self.navigationController.navigationBar.alpha = 1;
}

-(void)setupUI{
    self.navigationItem.title = @"店铺收藏";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"编辑" style:UIBarButtonItemStylePlain target:self action:@selector(editor)];
//    [self.navigationItem.rightBarButtonItem.title sizeWithFont:[UIFont systemFontOfSize:12]];
    [self.navigationItem.rightBarButtonItem setTintColor:[UIColor grayColor]];
    //中间View
    UIView *middleView = [[UIView alloc]init];
    middleView.backgroundColor = [UIColor cz_colorWithHex:0xefefef];
    
    [self.view addSubview:middleView];
    UIImageView *NullImage = [[UIImageView alloc]init];
    [middleView addSubview:NullImage];
    NullImage.image = [UIImage imageNamed:@"v2_store_empty"];
    UILabel *NullLabel = [[UILabel alloc]init];
    [middleView addSubview:NullLabel];
    [NullLabel setTextColor:[UIColor grayColor]];
    NullLabel.text = @"您还没有收藏的店铺哦~";
    [NullLabel setFont:[UIFont systemFontOfSize:15]];
    //底部的添加店铺按钮View
    UIView *btnView = [[UIView alloc]init];
    btnView.backgroundColor = [UIColor cz_colorWithHex:0xffffff];
    [self.view addSubview:btnView];
    UIButton *addBtn = [[UIButton alloc]init];
    [btnView addSubview:addBtn];

    [addBtn setTitle:@"+ 新增店铺" forState:UIControlStateNormal];
    [addBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    addBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [addBtn.titleLabel setTintColor:[UIColor blackColor]];
    addBtn.backgroundColor = [UIColor yellowColor];
    //按钮的圆角
    [addBtn.layer setMasksToBounds:YES];
    [addBtn.layer setCornerRadius:6.0];
    addBtn.backgroundColor = [UIColor cz_colorWithHex:0xffd700];
    //约束
    [btnView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.height.equalTo(@44);
    }];
    [addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(btnView);
        make.top.mas_equalTo(btnView.mas_top).mas_offset(@8);
        make.height.equalTo(@29);
        make.width.equalTo(@191);
    }];
    
    [middleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).mas_offset(64);
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(btnView.mas_top);
    }];
   
    [NullImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(middleView.mas_top).mas_offset(@29);
        make.centerX.equalTo(middleView.mas_centerX);
    }];
    [NullLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(NullImage);
        make.top.mas_equalTo(NullImage.mas_bottom).mas_offset(@21);
    }];
    
    //新增店铺的按钮点击添加事件
    [addBtn addTarget:self action:@selector(addShop:) forControlEvents:UIControlEventTouchUpInside];
    //编辑按钮
    UIButton *editorButton = [[UIButton alloc]init];
    [editorButton setTitle:@"编辑" forState:UIControlStateNormal];
    editorButton.titleLabel.font = [UIFont systemFontOfSize:15];
    [editorButton setTintColor:[UIColor grayColor]];
    //替换navigationController
	AXFWhiteNavView *whiteNavView = [[AXFWhiteNavView alloc] init];
    [whiteNavView addSubview:editorButton];
	
	[whiteNavView setTitleName:@"店铺收藏" andFunctionName:nil];
	
	whiteNavView.delegate = self;
	
	[self.view addSubview:whiteNavView];
	
	[whiteNavView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.right.top.offset(0);
		make.height.mas_equalTo(kNAVBARH + 20);
	}];
    [editorButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(whiteNavView).offset(-16);
        make.centerY.equalTo(whiteNavView);
        make.height.equalTo(@16);
        make.width.equalTo(@33);
    }];
}

- (void)backToViewController {
	[self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
